package edu.gatech.cs2340.mule.view;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.border.LineBorder;

import edu.gatech.cs2340.mule.presenter.MuleGamePresenter;

/**
 * Panel that holds the buttons that lead to each panel corresponding
 * to the establishments in the town
 * 
 * @author J.R. O'Donnell
 * 
 */
public class TownPanel extends JPanel {

	private static final int HGAP = 50;
	private static final int VGAP = 50;
	
	private JButton pubButton;
	private JButton landOfficeButton;
	private JButton storeButton;
	private JButton assayOfficeButton;
	private JButton exitButton;
	
	/**
	 * Create the panel.
	 */
	public TownPanel() {
		GridLayout layout = new GridLayout(3, 2);
		layout.setHgap(HGAP);
		layout.setVgap(VGAP);
		
		setLayout(layout);
		setBackground(MuleGamePresenter.BACKGROUND_COLOR);
		
		pubButton = new JButton();
		pubButton.setIcon(new ImageIcon("Images\\icon_pub.png"));
		pubButton.setBackground(MuleGamePresenter.BACKGROUND_COLOR);
		pubButton.setBorder(new LineBorder(MuleGamePresenter.BACKGROUND_COLOR, 2));
		add(pubButton);
		
		landOfficeButton = new JButton();
		landOfficeButton.setIcon(new ImageIcon("Images\\icon_landoffice.png"));
		landOfficeButton.setBackground(MuleGamePresenter.BACKGROUND_COLOR);
		landOfficeButton.setBorder(new LineBorder(MuleGamePresenter.BACKGROUND_COLOR, 2));
		add(landOfficeButton);
		
		storeButton = new JButton();
		storeButton.setIcon(new ImageIcon("Images\\icon_shop.png"));
		storeButton.setBackground(MuleGamePresenter.BACKGROUND_COLOR);
		storeButton.setBorder(new LineBorder(MuleGamePresenter.BACKGROUND_COLOR, 2));
		add(storeButton);
		
		assayOfficeButton = new JButton("Assay Office");
		assayOfficeButton.setBackground(MuleGamePresenter.FOREGROUND_COLOR);
		assayOfficeButton.setForeground(MuleGamePresenter.BACKGROUND_COLOR);
		assayOfficeButton.setBorder(new LineBorder(MuleGamePresenter.BACKGROUND_COLOR, 2));
		add(assayOfficeButton);
		
		exitButton = new JButton();
		exitButton.setIcon(new ImageIcon("Images\\icon_exit.png"));
		exitButton.setBackground(MuleGamePresenter.BACKGROUND_COLOR);
		exitButton.setBorder(new LineBorder(MuleGamePresenter.BACKGROUND_COLOR, 2));
		add(exitButton);

	}
	
	/**
	 * 
	 * @param a the action listener to be added to the exit button
	 */
	public void addExitListener(ActionListener a) {
		exitButton.addActionListener(a);
	}
	
	/**
	 * 
	 * @param a the action listener to be added to the store button
	 */
	public void addStoreListener(ActionListener a) {
		storeButton.addActionListener(a);
	}
	
	/**
	 * 
	 * @param a the action listener to be added to the pub button
	 */
	public void addPubListener(ActionListener a) {
		pubButton.addActionListener(a);
	}
	
	/**
	 * 
	 * @param a the action listener to be added to the land office button
	 */
	public void addLandOfficeListener(ActionListener a) {
		landOfficeButton.addActionListener(a);
	}
}
